package com.ars.common.servlet.admin.material;

import com.ars.common.beans.Active.Active;
import com.ars.common.beans.User.User;
import com.ars.common.dao.activity.FindClassActive;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import java.sql.SQLException;
import java.util.ArrayList;

/*
* @Author: Arslinth
* @Date: 2024/8/9 15:09
* 根据登录的用户ID进行查找活动的班级材料
* */

@WebServlet("/ClassMaterial")
public class ClassMaterial extends HttpServlet {
    public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
    {
        User logUser = (User) request.getSession().getAttribute("LogUser");
        String logId = logUser.getUserID();
        String Class = logId.substring(0,9);

        ArrayList<Active> active = new ArrayList<>();

        //在数据库中查找班级活动
        try {
            active = new FindClassActive().findClassActive(Class);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }

        request.setAttribute("active", active);
        request.getRequestDispatcher("admin/classMaterialInf.jsp").forward(request, response);

    }

    public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
    {

    }
}
